/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package classes;

import java.io.IOException;
import java.io.PrintWriter;
import javax.servlet.RequestDispatcher;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import pojo.Book;
import pojo.BookHome;

/**
 *
 * @author amr
 */
public class DeleteBook extends HttpServlet {
    
    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response)
            throws ServletException, IOException {
        String isbn = request.getParameter("deletedBookISBN");
        BookHome bookHome = new BookHome();
        Book book = bookHome.findById(Integer.parseInt(isbn));
        bookHome.delete(book);
        RequestDispatcher requestDispatcher = request.getRequestDispatcher(request.getRequestURL().toString());
        requestDispatcher.include(request, response);
        PrintWriter out = response.getWriter();
        try {
            out.println();
            
        } finally {
            out.close();
        }
    }
}
